<?php  
$this->db->order_by('jonu_menu_order', 'asc');
$q_menu = $this->db->get('jonu_menu');
$menu = $q_menu->result_array();
?>
<div id="sticky-menu">
	<nav class="navbar top-nav" role="navigation">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
					<i class="fa fa-reorder"></i>
				</button>
				<div class="logojgj">
					<img src="<?php echo base_url('asset/img/logowhite.png') ?>"  width="100%">
				</div>
				<a class="navbar-brand" href="<?php echo site_url() ?>">Jogja Nuws</a>
				<?php if(get_cookie("c_usr_id") == "" || get_cookie("c_usr_usrname") == "" || get_cookie("c_usr_fullname") == ""): ?>
					<button id="login-mob-toggle"><i class="fa fa-sign-in"></i></button>
				<?php else: ?>
					<?php if(get_cookie('c_usr_photo') != ""): ?>
						<a id="loggedin-user-menu-mob-toggle" href="#" class="logedin-user-mob">
							<img src="<?php echo base_url('asset/img/auth-foto/'.get_cookie('c_usr_photo')) ?>">
						</a>
					<?php else: ?>
						<a id="loggedin-user-menu-mob-toggle" href="#" class="logedin-user-mob">
							<img src="<?php echo base_url('asset/img/auth-foto/default-foto.png') ?>">
						</a>
					<?php endif; ?>
				<?php endif; ?>
			</div>
			<form action="<?php echo site_url('user/login_check') ?>" id="frm-login-mob" method="post">
				<span class="nav-input-mob">
					<input type="text" name="usr_username" class="form-control" placeholder="Username" required="required"/>	
				</span>
				<span class="nav-input-mob">
					<input type="password" name="usr_pass" class="form-control" placeholder="Password" required="required"/>
				</span>
				<input type="submit" name="btn_login_usr" id="btn-login-mob" value="Login" />
				<small>Tidak punya akun. <a href="<?php echo site_url('home/register') ?>">Daftar sekarang.</a></small>
			</form>
			<div id="loggedin-user-menu-mob">
				<a data-toggle="modal" href="#myModal" title="Post Baru"><i class="fa fa-plus fa-fw"></i></a>
				<a href="<?php echo site_url('user/pengaturan') ?>" title="Pengaturan"><i class="fa fa-cog fa-fw"></i></a>
				<a href="<?php echo site_url('user/logout') ?>" title="Logout"><i class="fa fa-power-off fa-fw"></i></a>
			</div>

			<div class="collapse navbar-collapse navbar-ex1-collapse">
				<ul class="nav navbar-nav">
					<?php foreach($menu as $menu_rec): ?>
						<li><a href="<?php echo $menu_rec['jonu_menu_link'] ?>" title="<?php echo $menu_rec['jonu_menu_text'] ?>"><?php echo $menu_rec['jonu_menu_text'] ?></a></li>
					<?php endforeach; ?>
				</ul>

				<ul class="nav navbar-nav navbar-right">
					<?php if(get_cookie("c_usr_id") == "" || get_cookie("c_usr_usrname") == "" || get_cookie("c_usr_fullname") == ""): ?>												
						<a id="login-toggle" class="nav-btn" href="#">Login</a>
						<form action="<?php echo site_url('user/login_check') ?>" id="frm-login" method="post">
							<label>Username</label>
							<input type="text" name="usr_username" class="form-control"/>
							<label>Password</label>
							<input type="password" name="usr_pass" class="form-control"/>
							<input type="submit" name="btn_login_usr" id="btn-login" value="Login" />
							<small>Tidak punya akun. <a href="<?php echo site_url('home/register') ?>">Daftar sekarang</a></small>
						</form>						
					<?php else: ?><!-- berhasil login -->						
						<div class="loguser">
							<?php if(get_cookie('c_usr_photo') != ""): ?>
								<a id="loggedin-user-menu-toggle" class="logedin-user kanan">
									<img src="<?php echo base_url("asset/img/auth-foto/".get_cookie('c_usr_photo')); ?>" width="100%" alt="foto profil">
								</a>
							<?php else: ?>
								<a id="loggedin-user-menu-toggle" class="logedin-user kanan">
									<img src="<?php echo base_url('asset/img/auth-foto/default-foto.png'); ?>" width="100%" alt="foto profil">
								</a>
							<?php endif; ?>							
							<a href="#" class="logedin-username kanan"><?php echo get_cookie('c_usr_fullname') ?></a>
							<div class="sambungfloat"></div>
						</div>

						<ul id="loggedin-user-menu">
							<?php if(get_cookie('c_usr_status') == "verified"): ?>
								<li><a data-toggle="modal" href="#myModal"><i class="fa fa-plus fa-fw"></i> Post Baru</a></li>
								<li><a href="<?php echo site_url('user/pengaturan') ?>"><i class="fa fa-cog fa-fw"></i> Pengaturan</a></li>
							<?php endif; ?>							
							<li><a href="<?php echo site_url('user/logout') ?>"><i class="fa fa-power-off fa-fw"></i> Logout</a></li>
						</ul>						
					<?php endif; ?>
					
				</ul>
			</div><!-- /.navbar-collapse -->
		</div>
	</nav>
	<nav class="navbar second-nav" role="navigation">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex2-collapse">
					<i class="fa fa-chevron-down"></i>
				</button>
				<a class="navbar-brand" href="#"><i class="fa fa-fire"></i> Hot Topik</a>
			</div>			

			<div class="collapse navbar-collapse navbar-ex2-collapse">
				<ul class="nav navbar-nav">
					<?php foreach($category as $category_rec): ?>
						<?php if(strtolower($category_rec['jonu_category_alias']) != "pow"): ?>
							<li>
								<a href="<?php echo site_url("home/category/$category_rec[jonu_category_slug]") ?>" title="<?php echo $category_rec['jonu_category_name'] ?>"><?php echo $category_rec['jonu_category_alias'] ?></a>
							</li>
						<?php endif; ?>
					<?php endforeach; ?>					
				</ul>
			</div><!-- /.navbar-collapse -->
		</div>
	</nav>
</div>

<?php if(get_cookie('c_usr_status') == "verified"): ?>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<!--<div id="ex-modal">-->
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-body">
					<form id="frm-new-post" action="<?php echo site_url('user/store_post') ?>" method="post" enctype="multipart/form-data">
						<div id="post-area-bg">
							<label>Judul</label>
							<input type="text" name="post_title" class="form-control input-sm"/>
							<label>Konten</label>
							<textarea name="post_content" class="form-control input-sm" ></textarea>			
							<label>Kategori</label><br/>
							<div id="cat-container">
								<?php $no_cat = 1 ?>
								<?php foreach($category as $newpost_cat): ?>
									<span class="cat-col">
										<input class="new_post_cat" type="checkbox" name="cat<?php echo $no_cat ?>" value="<?php echo $newpost_cat['jonu_category_id'] ?>" title="<?php echo $newpost_cat['jonu_category_name'] ?>"> <?php echo $newpost_cat['jonu_category_alias'] ?>
									</span>	
									<?php $no_cat++ ?>
								<?php endforeach; ?>						
							</div>
						</div>
						<div id="post-area-sm">
							<label>Foto</label>
							<input type="file" name="post_foto"  style="margin-bottom: 15px;" />		
							<label>Lokasi</label>	

							<fieldset class="fisarmonica">
								<div class="input_dinamici">			
									<span for="latitude"><input class="form-control input-sm" type="hidden" name="post_latitude" id="latitude"/></span>
									<span for="longitude"><input class="form-control input-sm" type="hidden" name="post_longitude" id="longitude"/></span>
								</div>
							</fieldset>
							<div id="maps" style="margin-bottom: 10px;"></div>
							<div for="address" name="post_location" class="input-group" style="margin-bottom: 10px;">
								<input type="text" class="form-control input-sm" name="post_location" id="address" placeholder="Tulis, lalu tekan tombol cari"/>
								<span class="input-group-btn">
									<button id="getmap" class="btn btn-sm btn-default" type="button"><i class="fa fa-search"></i></button>
								</span>
							</div>   			
						</div>	
						<input type="submit" class="btn btn-jonu btn-sm" style="clear:both; float:left" value="Publish Post" name="btn_new_post"/>
					</form>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div>
<?php endif; ?>